define(["app"], function(app) {
	var deps = ["$http", "BaseService"];
	
	function resource($http, BaseService) {
		return initSpaceResource($http,BaseService.restfulUrl + "space/");
	}
	var postHeader = {
			"Content-Type" : "application/x-www-form-urlencoded;charset=utf-8"
	};
	function initSpaceResource($http,spaceUrl){
		return {
			getSpace:function(){
				return $http.get(spaceUrl+'getSpace',{});
			},
			saveSpace:function(spaceVo){
				return $http.post(spaceUrl + "saveSpace", angular.toJson(spaceVo));
			},
            getPinyin:function(data){
                return $http.get(spaceUrl+"getPinyin",{
                    params: {
                        spaceName:data
                    }
                });

            },
            getSpaceById:function(data){
                return $http.get(spaceUrl+"getSpaceById",{
                    params:{
                        spaceId:data
                    }
                });
            },
            updateSpace:function(spaceVo){
                 return $http.post(spaceUrl+"updateSpace",angular.toJson(spaceVo));
            },
            resetPasswords:function(spaceIds,password){
                return $http.post(spaceUrl+"resetMasPassWord",{
                    spaceIds : spaceIds,
                    password : password
                },{
                    headers: postHeader
                });
            },
            getSpaceBySpaceName:function(spaceName){
                return $http.get(spaceUrl+"getSpaceBySpaceName",{
                    params:{
                        spaceName:spaceName
                    }
                });
            }
		};
	}
	resource.$inject = deps;
	app.lazy.factory("SpaceResource", resource);
});
